package com.myapp.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Transactional;

import com.myapp.dao.RoleDao;
import com.myapp.model.Role;

public class RoleDaoImpl extends GenericDaoImpl <Role,Long> implements RoleDao{

	public RoleDaoImpl(Class<Role> clazz) {
		super(clazz);
	}

	@Autowired
    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    @Transactional
	public Role findByRoleNmae(String roleName) {
		return null;
	}

	public void saveRole(Role role) {
        hibernateTemplate.saveOrUpdate(role);
	}

    @Transactional(readOnly = true)
    public List<Role> findAllRole() {
        return hibernateTemplate.find("from Role");
    }
}
